<template>
  <div>
    <div class="quote-board">
      <article class="flex-box">
        <div>
          <h1>预估报价</h1>
          <em>￥{{price}}</em>
          <div class="detail">
            <p>
              共有{{verison_count}}个平台，{{page_count}}个功能
              <button @click="hide">{{hideWords}}</button>
            </p>
          </div>
        </div>
        <div class="right">
          <button>
             <router-link class="link" to="/quote/step2Setting">调整需求重新计算</router-link>
          </button>
          <button>
            下载报价表
          </button>
          <button>
             我要开发
          </button>
        </div>
      </article>
    </div>
    <div class="quote-board price-list" v-if="isShow.baojia">
      <h3>报价表</h3>
      <div class="date-time content">
        <table border="1">
          <tr>
            <th>应用版本</th>
            <th>名称</th>
            <th>数量</th>
            <th>价格</th>
            <th>费用</th>
          </tr>

          <template v-for="item in checklist">
            <tr>
              <td v-if="item.version == 0">无版本</td>
              <td v-else>{{item.version_str}}</td>
              <td>{{item.name}}</td>
              <td>{{item.num}}</td>
              <td>{{item.price}}</td>
              <td>{{item.price*item.num}}</td>
            </tr>
          </template>
        </table>
      </div>
      
    </div>
  </div>
</template>

<script>
  import axios from 'axios'
  export default{
    name:'step3',
    created: function() {
          var that=this;
          var checklist=localStorage.getItem('list')?JSON.parse(localStorage.getItem('list')):[];;
          that.checklist=checklist;
          var price=0;
          var versions=[];
          that.checklist.forEach(function(value,index,array){
              price+=parseInt(value.price);
              if(versions.indexOf(value.version) ==-1){
                  versions.push(value.version);
              }
          });
         that.price=price;
         that.verison_count=versions.length;
         that.page_count=that.checklist.length;
   },
    data() {
      return {
        price: '',
        hideWords: '隐藏报价表',
        verison_count:0,
        page_count:0,
        checklist:[],
        info:[],
        isShow:{
          technology: true,
          functions: true,
          cost: true,
          baojia:true,
        }
      }
    },
    methods: {
      hide(){
        if(this.isShow.baojia){
              this.hideWords="显示报价表";
          }else{
              this.hideWords="隐藏报价表";
        }
        this.isShow.baojia=!this.isShow.baojia;
      },
      tabLabel(item){
        if(item == 'all'){
          for(let i in this.isShow){
            this.isShow[i] = true;
          }
        }else {
          for(let i in this.isShow){
            this.isShow[i] = false;
            if(i == item){
              this.isShow[i] = true;
            }
          }
        }
      },
    }
  }
</script>

<style scoped>
  .quote-board {
    margin: 2rem auto 0;
    max-width: 980px;
    padding: 3rem 3rem 4rem;
    border-radius: .4rem;
    background-color: #fff;
    width: 100%;
  }

  article {
    min-height: 20.5rem;
    padding: 2rem 0 2rem 3rem;
    background-color: rgba(221,227,235,.2);
    border-radius: inherit;
    display: -ms-flexbox;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .quote-board article h1 {
    font-size: 2rem;
    font-weight: 400;
    color: #000;
    margin: 0 0 1.6rem;
  }
  .quote-board article em {
    display: block;
    margin-left: .5rem;
    font-size: 3.5rem;
    font-style: normal;
    color: #4289db;
  }
  .quote-board article em:after {
    content: "\5143";
    font-size: 1.5rem;
  }
  .quote-board article .detail {
    margin: 1.6rem 0 0;
  }
  .quote-board article p {
    line-height: 1.5rem;
    font-size: 1rem;
    margin-bottm: .5rem;
  }
  .quote-board .detail button {
    padding: .1rem .5rem;
    line-height: 1.4em;
    height: auto;
    width: auto;
    background-color: hsla(212,9%,63%,.5);
    box-shadow: none;
    margin-left: .5rem;
    color: #fff;
    float: none;
    cursor: pointer;
    border-radius: .4rem;
    box-sizing: border-box;
    border: 0;
    box-shadow: 0 3px 3px rgba(45,51,56,.2);
    outline: none;
  }
  .quote-board article .right {
    width: 40%;
    height: 100%;
    /*padding-top: 10rem;*/
    border-left: 1px solid hsla(212,9%,63%,.2);
    text-align: center;
  }
  .quote-board article .right button {
    color: #4289db;
    margin-top: 1rem;
    background-color: #fff;
    border: 1px solid hsla(212,9%,63%,.2);
    height: 3rem;
    width: 14.3rem;
    font-size: 1rem;
    border-radius: .4rem;
    cursor: pointer;
  }
  .quote-board article .right .link {
    display: inline-block;
    width: 100%;
    height: 100%;
    color: #4289db;
    line-height: 3rem;
  }
  .price-list h3 {
    font-size: 1.6rem;
    text-align: center;
  }
  .price-list .line {
    padding-top: 1.2rem;
    width: 100%;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
  }
  .price-list .line ul {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    border: 1px solid hsla(212,9%,63%,.3);
  }
  .price-list .line ul li {
    position: relative;
    width: 10rem;
    height: 2.4rem;
    line-height: 2.4rem;
    color: #979fa8;
    font-size: 1rem;
    text-align: center;
    background: #fff;
    border-left: 1px solid hsla(212,9%,63%,.3);
  }
  .price-list .line ul li label {
    display: inline-block;
    width: 100%;
    height: 100%;
    cursor: pointer;
  }
  .price-list .line ul li:first-child {
    border-left: none;
  }
  .price-list .line ul li input[type="radio"] {
    position: absolute;
    top: 0;
    visibility: hidden;
  }
  .price-list .line ul li input[type="radio"]:checked + label {
    background: #4289db;
    color: #fff;
  }
  .price-list .date-time {
    width: 100%;
    margin: 40px auto 0;
    background: #c9ccd2;
  }
  .price-list .date-time h4 {
    font-size: 1.2rem;
    padding: 0.7rem;
    text-align: center;
    color: #fff;
  }
  .price-list .date-time table {
    \width: 100%;
    background: #fff;
    border-collapse:collapse;
    border-color: hsla(212,9%,63%,.2);
  }
  .price-list .date-time table td, .price-list .date-time table th {
    padding: 0.5rem;
    text-align: center;
  }
  .price-list .date-time table th {
    background: #f3f5f7;
  }
</style>
